<template>
	<view class="container">
		<view class="headerBg">
			<image src="../../static/bg.png" mode="scaleToFill"></image>
		</view>
		<view class="content">
			<view class="results">
				<view class="result_itm">
					<text>考试结果：</text>
					<text v-if="result.examResults==0">未参考</text>
					<text v-if="result.examResults==1">及格</text>
					<text v-if="result.examResults==2" class="warnTxt">不及格</text>
				</view>
				<view class="result_itm">
					<text>考试成绩：</text>
					<text>{{result.score}}</text>
				</view>
				<view class="result_itm">
					<text>考试用时：</text>
					<text>{{result.unavailable}}</text>
				</view>
				<view class="result_itm">
					<text>获得学分：</text>
					<text>{{result.obtainLearningScore}}</text>
				</view>
			</view>
			<view class="layout-between btn_group">
				<view class="back_btn">
					<u-button text="返回" color="linear-gradient(to right, rgb(70, 242, 242), rgb(126, 138, 240))"
						@click="toBack"></u-button>
				</view>
				<view class="parsing_btn">
					<u-button text="查看解析" color="linear-gradient(to right, #7774ff, #017ffd,#01b1fd)"
						@click="toParsing(answerList)"></u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				answerList: [],
				result: null,
			}
		},
		onLoad(options) {
			if (options.examParam) {
				this.answerList = JSON.parse(options.examParam)
				this.result = JSON.parse(options.resultParam)[0]
			}
		},
		methods: {
			toBack() {
				uni.switchTab({
					url: '/pages/onlineTesting/multipleChoice'
				})
			},
			toParsing(list) {
				let sExamList = JSON.stringify(list)
				uni.navigateTo({
					url: `/pages/onlineTesting/answerKey?answerParam=${sExamList}&userAnswerList=${JSON.stringify(this.result.userAnswers)
}`
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		width: 100%;
		position: relative;
		background: #F2F2F2;
		height: calc(100vh - 44px);
	}

	.headerBg {
		width: 100vw;
		height: 20vh;
		position: relative;

		image {
			width: 100%;
			height: 100%;
			opacity: 0.7;
		}
	}

	.content {
		margin: 40rpx;
		padding: 20rpx 30rpx;
		box-sizing: border-box;
		background: #fff;
		box-shadow: 4px 4px 10px #888888;
		border-radius: 20rpx;
		position: absolute;
		top: 11vh;
		width: 90%;
		left: 0;
	}

	.results {
		padding: 20rpx 80rpx;
		box-sizing: border-box;

		.result_itm {
			padding: 20rpx 30rpx;
			box-sizing: border-box;
		}
	}

	.btn_group {
		margin-top: 150rpx;
		width: 100%;
		position: relative;

		.back_btn {
			width: 40%;
		}

		.parsing_btn {
			width: 40%;
		}
	}
	.warnTxt {
		color: #E13124 !important;
		font-size: 30rpx !important;
	}
</style>